package com.itcoon.cloud.framework.ex.config;

import com.itcoon.cloud.framework.ex.register.DefaultErrorCodeRegister;
import com.itcoon.cloud.framework.ex.register.IErrorCodeRegister;
import com.itcoon.cloud.framework.ex.task.ErrorCodeRegisterTask;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;

import java.util.List;

@AutoConfiguration
public class ExConfiguration {

    @Bean
    @ConditionalOnMissingBean(IErrorCodeRegister.class)
    public IErrorCodeRegister errorCodeRegister(){
        return new DefaultErrorCodeRegister();
    }

    @Bean
    public ErrorCodeRegisterTask errorCodeRegisterTask(IErrorCodeRegister errorCodeRegister, List<ExRegistryConfigurer> exRegistryConfigurers){
        return new ErrorCodeRegisterTask(errorCodeRegister, exRegistryConfigurers);
    }

}
